/**
  * 服务器命令返回
  * by dily
  * (c) copyright 2014 - 2035
  * All Rights Reserved. 
  */
module game {
    export class Processor_HCJLB extends puremvc.SimpleCommand implements puremvc.ICommand {
        public constructor() {
            super();
        }
        public static NAME: string = "Processor_HCJLB";
        private hcjlbProxy: HcjlbProxy = null;
        /**
         * 注册消息
         */
        public register(): void {
            this.facade.registerCommand("Processor_HCJLB", Processor_HCJLB);
        }

        public execute(notification: puremvc.INotification): void {
            this.hcjlbProxy = HcjlbProxy.getProxy();
            var Body: any = notification.getBody();//携带数据
            let msgdata = DataParser.WSReceiveMsg(RegDataHcjlb, Body);

            let i = 0;
            if (Global.isEmpty(msgdata)) {
                return;
            }
            let mainCmd = msgdata["mainCmd"];
            let subCmd = msgdata["subCmd"];
            let data = msgdata["msgData"];
            switch (mainCmd) {
                case 1: {
                    if (subCmd == 100) {//登陆成功
                        this.hcjlbProxy.login(data);
                    }
                    if (subCmd == 101) {//登陆异常
                        Global.tipShow(data["szDescribeString"]);
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.HCJLB);
                        InstructionsEnum.ID_GAME = "";
                    }
                    if (subCmd == 102) { //登陆完成
                        let obj = {
                            wVisit: 0,
                            wVersion: 101122049,
                            wGameVersion: 101122049
                        }
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.HCJLB, RegDataHcjlb.CMD_GF_GameOption, obj, true);
                    }
                    if (subCmd == 103) { //回到其他房间
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.HCJLB);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.HALL_RECONNECTGAME, data["wServerID"]);
                    }
                    if (subCmd == 104) {//中途断线重连
                        this.hcjlbProxy.login(data);
                    }
                    break;
                }
                case 2: {
                    if (subCmd == 101) {//房间配置
                        this.hcjlbProxy.getRoomInfo(data);
                    };
                    if (subCmd == 103) {//完成配置

                    };
                    break;
                }
                case 3: {
                    if (subCmd == 100) {//刷新广场人员信息
                        this.hcjlbProxy.userJoinSquare(data)
                    };
                    if (subCmd == 101) {//
                        this.hcjlbProxy.getUserInfo(data);
                    }
                    if (subCmd == 102) {//我分配到的座位
                        this.hcjlbProxy.userStateModify(data);
                    }
                    if (subCmd == 103) {//钱不够入座
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.HCJLB)
                        Global.tipShow(data["szDescribeString"])
                    }
                    break;
                }
                case 4: {
                    if (subCmd == 100) {//请求坐下
                        let obj = {
                            wTableID: 65535,
                            wChairID: 65535,
                            szInsurePass: ""
                        }
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.HCJLB, RegDataHcjlb.CMD_GP_UserQuickSitdown, obj, true);
                    }
                }
                case 8: {
                    if (subCmd == 200) {//
                        switch (data["wType"]) {
                            case 256:
                                let obj = {
                                    CODE: PanelNotify.HCJLB.CLOSE_PLAY_GAME,
                                    TEXT: "抱歉！您的金币不足，请前往充值！",
                                    NEXT: true,
                                }
                                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
                                break;
                            case 512:
                                SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.HCJLB);
                                Global.tipShow("房间已关闭")
                                break;
                            case 515:
                                SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.HCJLB);
                                Global.tipShow("房间已关闭")
                                break;
                        }

                    };
                    break;
                }
                case 100: {
                    if (subCmd == 100) {
                    //     //空闲
                    //     if (data["cbGameStatus"] == 0) {
                    //         RegDataHcjlb.MainCMD_MsgId[100][101] = RegDataHcjlb.free
                    //     }
                    //     // 游戏中
                    //     if (data["cbGameStatus"] == 100 || data["cbGameStatus"] == 101) {
                    //         RegDataHcjlb.MainCMD_MsgId[100][101] = RegDataHcjlb.gameStart
                    //     }
                    }
                    if (subCmd == 101) {//中途加入
                        this.hcjlbProxy.dataRecovery(data)
                    }
                    if (subCmd == 200) {//后端推送消息
                        if (data["wType"] == 515) {
                            Global.tipShow(data["szString"]);
                        } else {
                            EffectUtils.textFadeAway(data["szString"]);
                        }
                    }
                    break;
                }
                case 200: {
                    if (subCmd == 105) { //开奖
                        this.hcjlbProxy.lottery(data);
                    }
                    if (subCmd == 101) { //玩家下注
                        this.hcjlbProxy.userBets(data);
                    }
                    if (subCmd == 110) { //场景信息
                        this.hcjlbProxy.sceneInfo(data);
                    }
                    if (subCmd == 120) { //上庄列表
                        this.hcjlbProxy.continueCard(data);
                    }
                    if (subCmd == 104) { //取消上庄
                        this.hcjlbProxy.cancelCard(data);
                    }
                    if (subCmd == 102) { //申请上庄
                        this.hcjlbProxy.applyBanker(data);
                    }
                    if (subCmd == 111) { //庄家易主
                        this.hcjlbProxy.switches(data);
                    }
                    if (subCmd == 106) { //押注状态
                        this.hcjlbProxy.betState(data);
                    }
                    if (subCmd == 107) { //开奖状态
                        this.hcjlbProxy.lotteryState(data);
                    }
                    if (subCmd == 108) { //空闲状态
                        this.hcjlbProxy.freeState(data);
                    }
                    if (subCmd == 100) { //开始下注
                        this.hcjlbProxy.startBet(data);
                    }
                    break;
                }
            }
        }
    }
}
